/*
 * Hidden Equity LLC
 * Author: Maksym Fedyay, Kyiv, mcsimf@gmail.com
 * Date: 29.02.2012
 */

package com.hiddenequity.campaign_service;

import com.hiddenequity.acts.R;

import android.app.Activity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;

public class CampaignFormAddSetLogic {

	Activity _activity;

	
	
	/*
	 * Constructor
	 */
	public CampaignFormAddSetLogic(Activity activity){
		_activity = activity;
	}//Constructor

	
	
    /*
     * Form Logic
     */
    public void setLogic(View v){
    	
    	CheckBox cb_Mobile = (CheckBox) _activity.findViewById(R.id.cb_Mobile);
    	//CheckBox cb_Tablet = (CheckBox) _activity.findViewById(R.id.cb_Tablet);
    	
    	RadioButton rb_AllOS = (RadioButton) _activity.findViewById(R.id.rb_AllOS);
    	RadioButton rb_SelectOS = (RadioButton) _activity.findViewById(R.id.rb_SelectOS);
    	
		CheckBox cb_AndriodOS = (CheckBox) _activity.findViewById(R.id.cb_AndriodOS);
		CheckBox cb_iOS = (CheckBox) _activity.findViewById(R.id.cb_iOS);
		CheckBox cb_webOS = (CheckBox) _activity.findViewById(R.id.cb_webOS);
    	
		CheckBox cb_BidingLimit = (CheckBox) _activity.findViewById(R.id.cb_BidingLimit);
		EditText editBidingLimit = (EditText) _activity.findViewById(R.id.editBidingLimit);
		
    	// Delivery method
    	RadioButton rb_delivery_method_standart = (RadioButton) _activity.findViewById(R.id.rb_delivery_method_standart);
    	RadioButton rb_delivery_method_accelerated = (RadioButton) _activity.findViewById(R.id.rb_delivery_method_accelerated);
		
    	switch (v.getId()) {
			case R.id.cb_GoogleSearch:
				CheckBox cb_GoogleSearch = (CheckBox) _activity.findViewById(R.id.cb_GoogleSearch);
				CheckBox cb_SearchPartners = (CheckBox) _activity.findViewById(R.id.cb_SearchPartners);
				if(cb_GoogleSearch.isChecked()){
					cb_SearchPartners.setEnabled(true);					
				} else {
					cb_SearchPartners.setEnabled(false);						
				}
				break;
				
	        case R.id.cb_DisplayNetwork:
				CheckBox cb_DisplayNetwork = (CheckBox) _activity.findViewById(R.id.cb_DisplayNetwork);
				RadioButton rb_AllNetworks = (RadioButton) _activity.findViewById(R.id.rb_AllNetworks);
				RadioButton rb_Broadest = (RadioButton) _activity.findViewById(R.id.rb_Broadest);
				if(cb_DisplayNetwork.isChecked()){
					rb_AllNetworks.setEnabled(true);
					rb_Broadest.setEnabled(true);
				} else {
					rb_AllNetworks.setEnabled(false);						
					rb_Broadest.setEnabled(false);
				}
				break;

	        case R.id.cb_Mobile:
	            if(cb_Mobile.isChecked()){
	            	rb_AllOS.setEnabled(true);
	            	rb_SelectOS.setEnabled(true);
	        		if(rb_SelectOS.isChecked()){
		            	cb_AndriodOS.setEnabled(true);
		        		cb_iOS.setEnabled(true);
		        		cb_webOS.setEnabled(true);
	        		}
	            } else {
	            	rb_AllOS.setEnabled(false);
	            	rb_SelectOS.setEnabled(false);
	        		cb_AndriodOS.setEnabled(false);
	        		cb_iOS.setEnabled(false);
	        		cb_webOS.setEnabled(false);	
	            }
	        	break;
	            
	        case R.id.rb_AllOS:
        		cb_AndriodOS.setEnabled(false);
        		cb_iOS.setEnabled(false);
        		cb_webOS.setEnabled(false);	
	            break;
	            
	        case R.id.rb_SelectOS:
        		cb_AndriodOS.setEnabled(true);
        		cb_iOS.setEnabled(true);
        		cb_webOS.setEnabled(true);
        		break;
        		
	        case R.id.rb_BidingAutomatic:
	        	cb_BidingLimit.setEnabled(true);
	        	if(cb_BidingLimit.isChecked()){
	        		editBidingLimit.setEnabled(true); 
	        	}
	        	
	        	rb_delivery_method_accelerated.setEnabled(false);
	        	rb_delivery_method_standart.setEnabled(false);
	        	rb_delivery_method_standart.setChecked(true);
	        	
	            break;
	            
	        case R.id.rb_BidingManual:
	        	cb_BidingLimit.setEnabled(false);
	        	editBidingLimit.setEnabled(false);        	
	        	rb_delivery_method_accelerated.setEnabled(true);
	        	rb_delivery_method_standart.setEnabled(true);
	        	break;
	            
	        case R.id.cb_BidingLimit:
	        	if(cb_BidingLimit.isChecked()){
	        		editBidingLimit.setEnabled(true); 
	        	} else {
	        		editBidingLimit.setEnabled(false); 
	        	}    	
	            break;
    	}
	
    }//setLogic
}
